import logging
import time
import unittest
from selenium import webdriver
from unit_02.Page.Page1 import Page1
from selenium.webdriver.common.by import By
from ddt import ddt,file_data
from unit_02.Tools.Tools import Tools

@ddt
class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        # 初始化日志
        Tools().Log()
        print('start case')
        self.driver = webdriver.Firefox()
        # 浏览器事件 窗口最大化
        self.driver.maximize_window()

    def tearDown(self) -> None:
        print('end case')
        time.sleep(5)
        self.driver.quit()

    @file_data('data.yaml')
    def test_01(self,order):
        logging.info('sraet test_01')
        po = Page1(self.driver)
        po.login_luoji()
        # 隐式等待
        self.driver.implicitly_wait(5)
        # 悬浮 我的酒仙
        po.xf_wdjx()
        time.sleep(2)
        # 2.点击我的订单
        po.click_order()
        time.sleep(2)
        # 窗口切换
        po.new_window()
        time.sleep(3)
        # 断言 我的订单
        dy = self.driver.find_element(By.XPATH,'/html/body/div[5]/div[1]/em').text
        print('断言:',dy)
        self.assertIn('我的订单',dy)
        time.sleep(2)
        # 3.输入订单号 17250519111625507843
        po.sr_ddh(order)
        time.sleep(2)
        # 键盘回车事件
        po.enters()
        time.sleep(2)
        logging.info('end test_01')



if __name__ == '__main__':
    unittest.main()
